<admintpl file="header" />
<script type="text/javascript" src="public/js/My97DatePicker/WdatePicker.js?3"></script>
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li class="active"><a href="javascript:;">商户卡流量查询</a></li>
    </ul>
    <form class="well form-search" method="post" action="{:U('AdminCard/merchant')}">
        请选择时间：
        <input type="text" name="s_start_time" id="s_start_time" onclick="start_time()" style="width: 200px;" value="{$s_start_time}"/>
        &nbsp;&nbsp;
        ICCID：
        <input type="text" name="s_number" style="width: 200px;" value="{$s_number}" placeholder=""> <span style="color:red">注:多个号码之间用逗号隔开！</span>
        &nbsp;&nbsp;
        <!--所属人：-->
        <!--<select name="s_uid">-->
            <!--<option value="">全部</option>-->
            <!--<foreach name="user_list" item="uo">-->
                <!--<option value="{$uo.id}">{$uo.user_nickname}</option>-->
            <!--</foreach>-->
        <!--</select>-->
        <input type="submit" class="btn btn-primary" onclick="javascript:ajax_get_list(1);return false;" value="搜索" />

    </form>
    <form class="js-ajax-form" action="" method="post">

        <table class="table table-hover table-bordered table-list">
            <thead>
            <tr>
                <!--<td>所属用户</td>-->
                <td>ICCID</td>
                <td>卡号</td>
                <td>当月剩余流量</td>
                <td>当月月套餐</td>
                <td>当月增量包</td>
                <td>操作</td>
            </tr>
            </thead>
            <!--<foreach name="list" item="vo">-->
                <!--<tr>-->
                    <!--&lt;!&ndash;<td>{$vo.user_nickname}</td>&ndash;&gt;-->
                    <!--<td>{$vo.card_iccid}</td>-->
                    <!--<td>{$vo.card_number}</td>-->
                    <!--<td>{$vo.plus_flow}</td>-->
                    <!--<td>{$vo.package_data_month}</td>-->
                    <!--<td>{$vo.package_data_add}</td>-->
                    <!--<td><a href="{:U('AdminCard/detail',array('card_number'=>$vo['card_number'],'time'=>$s_start_time))}">查看详单</a></td>-->
                <!--</tr>-->
            <!--</foreach>-->
        </table>
        <div class="loading">
            <img src="__PUBLIC__/images/loading.gif" />
        </div>
        <div class="pagination"></div>
        <div style="float: right">
            <a  href="{:U('Download/current',array('type'=>'card_merchant'))}" class="btn btn-primary">下载当前</a>&nbsp;&nbsp;
            <a  href="{:U('Download/all',array('type'=>'card_merchant','s_start_time'=>$s_start_time,'s_number'=>$s_number))}" class="btn btn-primary" onclick="javascript:return confirm_download();">下载全部</a>
        </div>
    </form>
</div>
<script src="__PUBLIC__/js/common.js"></script>
<script>

    function start_time(){
        WdatePicker({dateFmt:'yyyy-MM'});
    }

    $(function(){
        $(".loading").hide();
    });

    function ajax_get_list(p){
        $(".tr-data").remove();
        $(".loading").show();
        var s_number = $("input[name='s_number']").val();
        var s_start_time = $("input[name='s_start_time']").val();
        if( p == '' || isNaN(p)){
            p = 1;
        }
        $.ajax({
            url:"{:U('AdminCard/merchant')}",
            async:true,
            dataType:"json",
            data:"s_number="+s_number+"&s_start_time="+s_start_time+"&p="+p,
            success:function(t){
                if(t.code == 0){
                    if(t.checkCard != ''){
                        alert(t.checkCard);
                    }
                    var content;
                    var d_length = t.data.length;
                    for(var i=0;i<d_length;i++){
                        var temp = t.data[i];
                        var detail_url = '{:U("AdminCard/detail")}&card_number='+temp.card_number+"&time="+s_start_time;
                        content = content+'<tr class="tr-data">'+
                                '<td>'+temp.card_iccid+'</td>'+
                                '<td>'+temp.card_number+'</td>'+
                                '<td>'+temp.plus_flow+'</td>'+
                                '<td>'+temp.package_data_month+'</td>'+
                                '<td>'+temp.package_data_add+'</td>'+
                                '<td><a href="'+detail_url+'">查看详单</a></td>'+
                                ' </tr>';
                    }
                    $(".loading").hide();
                    $(".table-list").append(content);
                    $(".pagination").html(t.page);

                }else{
                    alert("数据读取失败")
                }
            }
        });
    }
</script>
</body>
</html>